package com.huluobo.a2303mdmdemo.goods

import com.huluobo.a2303mdmdemo.goods.entity.CartEntity
import com.huluobo.a2303mdmdemo.goods.entity.GoodsEntity
import com.huluobo.a2303mdmdemo.goods.entity.GoodsEntityItem
import com.huluobo.lib_base.BaseRepo
import com.huluobo.lib_base.Res
import com.huluobo.lib_http.HttpType
import com.huluobo.lib_http.NetworkFactory
import kotlinx.coroutines.flow.Flow
import javax.inject.Inject

/**
 *  Created by LC on 2025/9/3.
 */
class GoodsRepo @Inject constructor() : BaseRepo() {
    private val apiService by lazy { NetworkFactory.factory(HttpType.VIDEO).create(ApiService::class.java) }

    fun getAllGoods(categoryId: Int, currentPage: Int, pageSize: Int): Flow<Res<GoodsEntity>> {
        return apiService.getAllGoods(categoryId, currentPage, pageSize)
    }

    fun addToCart(map: Map<String, Any>): Flow<Res<Any>> {
        return apiService.addToCart(mapToJson(map))
    }

    fun getCart(): Flow<Res<CartEntity>> {
        return apiService.getCart()
    }
}